<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <!-- 使用不同智能机的宽度 -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="renderer" content="webkit">
    <title>MissQ校花</title>
    <link rel="stylesheet" href="css/base.css"/>
    <link rel="stylesheet" href="css/drawmoney.css"/>
    <script src="js/jquery-1.12.3.min.js"></script>
    <script>
        ;(function(win, doc){
            function change(){
                doc.documentElement.style.fontSize=20*doc.documentElement.clientWidth/320+'px';
            }

            if(doc.documentElement.clientWidth>640){
                doc.documentElement.style.fontSize=20*640/320+'px';
            }else{
                change();
            }
            win.addEventListener('resize', change, false);
        })(window, document);

        function onBridgeReady(){
            WeixinJSBridge.call('hideOptionMenu');
        }

        if (typeof WeixinJSBridge == "undefined"){
            if( document.addEventListener ){
                document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
            }else if (document.attachEvent){
                document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
                document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
            }
        }else{
            onBridgeReady();
        }

        function GetQueryString(name)
        {
            var search = document.location.search;
            var pattern = new RegExp("[?&]"+name+"\=([^&]+)", "g");
            var matcher = pattern.exec(search);
            var items = null;
            if(null != matcher){
                try{
                    items = decodeURIComponent(decodeURIComponent(matcher[1]));
                }catch(e){
                    try{
                        items = decodeURIComponent(matcher[1]);
                    }catch(e){
                        items = matcher[1];
                    }
                }
            }
//                    alert(items)
            return items;
        }

        $(function(){
            var id=GetQueryString('userId');
            $('.drawrecord').attr('href','http://app.missquq.com/h5/rebBack/jumpList?userId='+id);
            $('.homepage').css('height',$(document).height());
            $.ajax({
//                type: 'GET',
                url: 'http://app.missquq.com/h5/rebBack/detail',
                dataType: 'json',
                data:{
                    userId:id
                },
                jsonp: 'callback',    // cbName
                dataType: 'jsonp', // 使用jsonp
                success: function(json) {
                    $('.homepage-bg img:first-child,.homepage-mainphoto img').attr('src','http://app.missquq.com'+json.avatar160);
                    $('.xingshang i').html(json.num);
                    if(json.gender==2){
                        $('.homepage-name span').html(json.nkname+'<img src="img/girl_icon.png"/>');
                    }else{
                        $('.homepage-name span').html(json.nkname+'<img src="img/boy_icon.png"/>');
                    }

                    $('.balanceNum').html(json.amount.toFixed(1));
                }
            });


            $('.popupBTN').on('click',function(){
                $('.cover,.drawmoney-popup').css('display','none');
//                        $('.drawMOney-phone-text').val('')
            });

            $('.getMoneyBTN').on('click',function(){
                if($('.getMoney > input').val()==''){
                    return false;
                }else if($('.getMoney>input').val()<20||$('.getMoney>input').val()>200){
                    $('.popupIcon').attr('src','img/drawmoney/pic-mistake.png');
                    $('.popupTextU').text('提现限额20~200元整');
                    $('.popupTextD').text('请重新输入');
                    $('.cover,.drawmoney-popup').css('display','block');
                }else if($('.getMoney>input').val()>parseInt($('.balanceNum').text())){
                    $('.popupIcon').attr('src','img/drawmoney/pic-mistake.png');
                    $('.popupTextU').text('余额不足');
                    $('.popupTextD').text('请重新输入');
                    $('.cover,.drawmoney-popup').css('display','block');
                }else{
                   $.ajax({
                       url: 'http://app.missquq.com//redpack/withdraw',
                       dataType: 'json',
                       data:{
                           amount:$('.getMoney > input').val(),
                           userId:id
                       },
                       jsonp: 'callback',    // cbName
                       dataType: 'jsonp', // 使用jsonp
                       success: function(json) {
                            console.log(json)
                           if(json.state==3){
                               $('.popupIcon').attr('src','img/drawmoney/popup.jpg');
                               $('.popupTextU').text('提现成功');
                               $('.popupTextD').text('请到微信中查看');
                               $('.cover,.drawmoney-popup').css('display','block');
                           }else{
                               $('.popupIcon').attr('src','img/drawmoney/pic-mistake.png');
                               $('.popupTextU').text('提现失败');
                               $('.popupTextD').text('请重新尝试');
                               $('.cover,.drawmoney-popup').css('display','block');
                           }
                       }
                   });
               }
            });



            $('.getMoney input').on('keyup',function(){
                var val=$(this).val();
                var r=/\D/gi;
                if(r.test(val)){
                    $(this).val(val.replace(/\D/gi,""));
                }else if(val){
                    $(this).val(parseInt(val));
                }else{
                    return false;
                }
            });

        });
    </script>
</head>
<body>
<div class="w640 mainbox homepage">
    <div class="homepage-bg">
        <img src="" alt="" class="blur"/>
        <div class="homepage-mainphoto"><img src="" alt=""/></div>
        <p class="homepage-name"><span></span></p>
        <div class="link">
        <span>
            <a href="drawmoney.html">更换账户</a><i class="bor"></i><a href="drawmoneylist.html" class="drawrecord">提现记录</a>
        </span>
        </div>
    </div>
    <div class="balance">
        <p class="balanceText">账户余额(元)</p>
        <p class="balanceNum"></p>
    </div>
    <div class="getMoney">
        <p class="balanceText">提现金额(元)</p>
        <input type="text" placeholder="20~200" onpaste="return false;"/>
        <p class="getMoneyHint">单次提现限额:20~200元整</p>
    </div>
    <div class="getMoneyBTN">提现</div>
    <div class="cover"></div>
    <div class="drawmoney-popup">
        <img src="img/drawmoney/popup.jpg" alt="" class="popupBG"/>
        <img src="" alt="" class="popupIcon"/>
        <p class="popupTextU"></p>
        <p class="popupTextD"></p>
        <button class="popupBTN">确定</button>
        <div class="line"></div>
    </div>
</div>
</body>
</html>